package Chapter6.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;

@Entity
@IdClass(Student1.StudentPk1.class)
public class Student1 implements Serializable {

	private static final long serialVersionUID = 1L;
	private String comment;
	private String stCd;
	private String name;

	public Student1() {
	}

	@Id
	public String getStCd() {
		return stCd;
	}

	public void setStCd(String stCd) {
		this.stCd = stCd;
	}

	@Id
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Student1(String comment) {
		this.comment = comment;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public class StudentPk1 implements Serializable {
		private static final long serialVersionUID = 1L;
		private String stCd;
		private String name;

		public StudentPk1() {
		}

		public StudentPk1(String stCd, String name) {
			this.stCd = stCd;
			this.name = name;
		}

		public String getStCd() {
			return stCd;
		}

		public void setStCd(String stCd) {
			this.stCd = stCd;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj) {
				return true;
			}
			if (!(obj instanceof StudentPK)) {
				return false;
			}
			StudentPK pk = (StudentPK) obj;
			return (this.name.equals(pk.getName()) && this.stCd.equals(pk
					.getStCd()));
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int hash = 17;
			hash = hash * prime + this.stCd.hashCode();
			hash = hash * prime + this.name.hashCode();
			return super.hashCode();
		}
	}
}
